package com.itfenghuang.day07;

import day06.Class;

import java.sql.*;

public class jdbc_atm {

    //传入查询sql 返回查询结果
    public static ResultSet select(String sql) throws SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/atm",
                "root", "123456");
        Statement stat = con.createStatement();

        ResultSet result = stat.executeQuery(sql);
        return result;
    }
    //传入查询sql 返回增删改
    public static int update(String sql) throws SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/atm",
                "root", "123456");
        Statement stat = con.createStatement();

        int result = stat.executeUpdate(sql);
        return result;
    }

//    public static ResultSet update(String sql) throws SQLException {
//        Class.forName("com.mysql.jdbc.Driver");
//        Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/atm",
//                "root", "123456");
//        Statement stat = con.createStatement();
//
//        ResultSet result = stat.executeUpdate(sql);
//        return result;
//    }








}
